#include "enemyplane.h"
#include<config.h>
EnemyPlane::EnemyPlane() {
    //敌机的资源加载
    m_enemy.load(ENEMY_PATH);

    //敌机的位置
    m_X=0;
    m_Y=0;

    //敌机状态
    m_Free=true;

    //敌机速度
    m_Speed=ENEMY_SPEED;

    //敌机矩形框（碰撞检测）
    m_Rect.setWidth(m_enemy.width());
    m_Rect.setHeight(m_enemy.height());
    m_Rect.moveTo(m_X,m_Y);


}

void EnemyPlane::updatePosition()
{
    //空闲敌机不计算坐标
    if(m_Free){
        return;
    }

    m_Y+=m_Speed;
    m_Rect.moveTo(m_X,m_Y);

    //超出屏幕-->free
    if(m_Y>=GAME_HEIGHT+m_Rect.height()){
        m_Free=true;
    }

}
